home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_basi / qbsvga.zip / MOUSDEMO.BAS < prev    next >
BASIC Source File  |  1996-07-01  |  4KB  |  129 lines

  1. '
  2. '  This is a simple MAIN routine to demonstrate use of the QBSVGA's mouse
  3. ' routines.  (You still need to link with QB.LIB or run QB with the /L
  4. ' option.)
  5. '
  6. '  Put the contents of REGTYPE.INC here.
  7. '
  8. '  Don't do anything if mouse driver isn't present.  (QRYMOUSE is the only
  9. ' mouse routine (indeed, the only one of any of the QBSVGA routines) that
  10. ' you can call without first setting the video mode with BSCREEN.)
  11. '
  12. IF QRYMOUSE=-1 THEN
  13. '
  14. '  Mouse position detector only works with graphics screens.
  15. '
  16. CALL BSCREEN(14!,7!,0!,0!)
  17. '
  18. '  For now, SETLIM will not be used to restrict mouse cursor movement past
  19. ' the default manner in which it was used in subroutine MOUSINIT (called
  20. ' by BSCREEN).  A later example will use SETLIM explicitly.  If it was
  21. ' going to be used here, the most logical place for it would be right
  22. ' here, before beginning a programming sequence using subroutine GETPOS.
  23. '
  24. A$="  Move mouse around and press a button.  To terminate this example,;"
  25. B$="leave the mouse at the same position and press any combination of"
  26. C$="buttons twice."
  27. CALL BPRINT("EEK!  A RODENT!  HELP!")
  28. CALL BPRINT(" ")
  29. CALL BPRINT("(Sorry, I couldn't resist.)")
  30. CALL BPRINT(" ")
  31. CALL BPRINT(A$)
  32. '
  33. '  The following call to BPRINT is used to put a "," at the end of the
  34. ' printed string represented by A$.  (BPRINT won't allow a comma to be
  35. ' explicitly printed at the end of a line.)
  36. '
  37. CALL BPRINT(" ")
  38. CALL BPRINT(B$)
  39. CALL BPRINT(C$)
  40. '
  41. '  If output position from GETPOS is same as last position, terminate
  42. ' loop.
  43. '
  44. X=-1 : Y=-1
  45. TOP1:
  46. XL=X : YL=Y
  47. CALL GETPOS(X,Y,BUTTON)
  48. CALL BLOCATE(10!,1!)
  49. A$="("+LTRIM$(RTRIM$(STR$(X)))+" , "+LTRIM$(RTRIM$(STR$(Y)))+")."
  50. A$="Cursor position = "+A$+"                                "
  51. CALL BPRINT(A$)
  52. IF BUTTON=0 THEN BUT$="left"
  53. IF BUTTON=1 THEN BUT$="right"
  54. IF BUTTON=2 THEN BUT$="middle"
  55. CALL BPRINT("You pressed the "+BUT$+" button.        ")
  56. IF ABS(XL-X)>.001 OR ABS(YL-Y)>.001 THEN GOTO TOP1
  57. '
  58. '  Use new example restricting cursor motion.
  59. '
  60. CALL BSCREEN(15!,7!,0!,0!)
  61. A$="Now I'm going to restrict the motion of the cursor in a higher video mode."
  62. CALL BPRINT(A$)
  63. CALL BPRINT(" ")
  64. A$="  Move mouse around and press a button.  To terminate example, leave"
  65. B$="the mouse at the same position and press any combination of buttons"
  66. C$="twice."
  67. CALL BPRINT(A$)
  68. CALL BPRINT(B$)
  69. CALL BPRINT(C$)
  70. CALL SETLIM(100!,100!,HMAX-100,VMAX-100)
  71. '
  72. '  Draw box to show where mouse limits are.
  73. '
  74. CALL BLINE(100!,100!,HMAX-100,VMAX-100,7!,"B")
  75. X=-1 : Y=-1
  76. TOP2:
  77. XL=X : YL=Y
  78. CALL GETPOS(X,Y,BUTTON)
  79. CALL BLOCATE(34!,1!)
  80. A$="("+LTRIM$(RTRIM$(STR$(X)))+" , "+LTRIM$(RTRIM$(STR$(Y)))+")"
  81. A$="Position = "+A$+"         "
  82. IF BUTTON=0 THEN BUT$="left"
  83. IF BUTTON=1 THEN BUT$="right"
  84. IF BUTTON=2 THEN BUT$="middle"
  85. CALL BPRINT(A$)
  86. CALL BPRINT("Button = "+BUT$+"          ")
  87. IF ABS(XL-X)>.001 OR ABS(YL-Y)>.001 THEN GOTO TOP2
  88. '
  89. '  Do example involving dragging box routine.
  90. '
  91. CALL BCLS(0!)
  92. CALL SETLIM(0!,0!,HMAX,VMAX)
  93. '
  94. '  Change colors.
  95. '
  96. MCOLOR=13
  97. A$="  Press and hold a button and move mouse around.  Release button when recta"
  98. A$=A$+"ngle"
  99. B$="is drawn however you want."
  100. CALL BPRINT(A$)
  101. CALL BPRINT(B$)
  102. CALL BOXDRAG(XP,YP,XR,YR,BUTTON)
  103. CALL BCLS(0!)
  104. A$="  Press a key and I will use the outputs of the BOXDRAG mouse routine to"
  105. B$="redraw your box."
  106. CALL BPRINT(A$)
  107. CALL BPRINT(B$)
  108. 10 IF INKEY$="" THEN GOTO 10
  109. XLEFT=XP : XRIGHT=XR : IF XR<XP THEN XLEFT=XR : XRIGHT=XP
  110. YLEFT=YP : YRIGHT=YR : IF YR<YP THEN YLEFT=YR : YRIGHT=YP
  111. CALL BCLS(0!)
  112. CALL BLINE(XLEFT,YLEFT,XRIGHT,YRIGHT,7!,"B")
  113. COLUMN=INT(XLEFT/8+.001)+2 : ROW=INT(YLEFT/16+.001)+2
  114. CALL BLOCATE(ROW,COLUMN)
  115. CALL BPRINT("This should be your box; press a key to quit.")
  116. CALL BLOCATE(ROW+1,COLUMN)
  117. CALL BPRINT("(Notice how I changed colors just to show that")
  118. CALL BLOCATE(ROW+2,COLUMN)
  119. CALL BPRINT("I was actually recreating your box?)")
  120. 20 IF INKEY$="" THEN GOTO 20
  121. CALL BSCREEN(0!,7!,0!,0!)
  122. ELSE
  123. PRINT
  124. PRINT "Install mouse driver!"
  125. END IF
  126. END
  127. '
  128. '  Put the contents of QBSVGA.BAS here.
  129.